
import QtQuick 2.8
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0

Item {
    readonly property bool softwareRendering: GraphicsInfo.api === GraphicsInfo.Software

    width: clock.implicitWidth
    height: clock.implicitHeight

    Rectangle {
        id: clock
        property date dateTime: new Date()
        anchors.horizontalCenter: parent.horizontalCenter
        height: 50
        width: time.implicitWidth + 40
        radius: 32
        color: '#73FFFFFF'

        Text {
            id: time
            anchors.centerIn: parent
            text : Qt.formatTime(clock.dateTime, conf("time.format")) + ', ' + Qt.formatDate(clock.dateTime, conf("date.format") == "" ? Qt.DefaultLocaleLongDate : conf("date.format"))
            color: conf("time.color")
            font.pointSize: conf("time.size")
            font.italic: conf("time.italic")
            font.bold: conf("time.bold")
            visible: conf("time.visible")
            Component.onCompleted: if (conf("time.font") != "") font.family = conf("time.font")
        }
    }

    // Conf
    function conf(key, section) {
        var sec = (section === undefined ? "clock" : section);
        var val = config[sec + "/" + key];
        if (val === "true") {return true;}
        if (val === "false") {return false;}
        return val;
    }
}
